<?php
#---------File Include
include_once 'conf/db-config.php';
error_reporting(0);
session_start();
$userPckage = $_REQUEST['package_no'];
$action = $_REQUEST['action'];
$user_id = $_REQUEST['user_id'];

if($action=="userPackage" || $action=="reviewPackage")
{
	
	$sql = "select * from tbl_admission_documents WHERE user_id=".$user_id." AND package_no=".$userPckage;
	$run = mysql_query($sql);
	while ($data = mysql_fetch_array($run))
	{
		$is_reviewed  = $data['is_review'];
		$package_no = $data['package_no'];
		$id = $data['id'];
		$schoolName = stripslashes($data['school_name']);
		$documentName = stripslashes($data['document_name']);
		$docPath = $data['document_path'];
		if(file_exists(str_ireplace("/","\\",$_SERVER["DOCUMENT_ROOT"]."mymba/".$docPath)) && $docPath!="" && strlen($docPath)>0)								
			$cropped_src = "http://localhost/mymba/".$docPath;
	}
	if($action=="userPackage")
	{
		$formAction = "saveAdmission.php";
	}
	else if($action=="reviewPackage" && $is_reviewed==0)
	{
		$formAction = "saveAdmission.php?action=review";
	}
	else if($action=="reviewPackage" && $is_reviewed==1)
	{
		$formAction = "saveAdmission.php?action=review2";
	}
	$html .= '<div id="test" style="width:500px">';
	$html ="<fieldset>";
	$html .= '<legend><b>Package '.$userPckage.' details :	</b></legend>';
	$html .= '<br />';	
	$html .= '<form id="frmAdmission" name="frmAdmission" action="'.$formAction.'" method="post" enctype="multipart/form-data" >';
	$html .= '<table cellpadding="0" cellspacing="0" >';
	$html .= '<tr>';
	$html .= '<td>';
	$html .= '<input type="hidden" id="package_no" name="package_no" value="'.$userPckage.'" />';
	$html .= 'School Name:';
	$html .= '</td>';
	$html .= '<td>';
	$html .= '<input type="text" name="txtSchoolName" id="txtSchoolName" value="'.$schoolName.'" />';
	$html .= '</td>';
	$html .= '</tr>';
	$html .= '<tr>';
	$html .= '<td>';
	$html .= 'Document Name:';
	$html .= '</td>';
	$html .= '<td>';
	$html .= '<input type="text" name="txtDocumentName" id="txtDocumentName" value="'.$documentName.'" />';
	$html .= '</td>';
	$html .= '</tr>';
	$html .= '<tr>';
	$html .= '<td colspan="2">';
	$html .= '<br /><span style="color:red;width:300px;">(** Please note that the Document name must be unique for each package. Thank you.)</span></td>';
	$html .= '</tr>';
	$html .= '<tr>';
	$html .= '<td>';
	$html .= 'Document:';
	$html .= '</td>';
	$html .= '<td>';
	$html .= '<input type="file" name="file" id="file" />';
	$html .= '</td>';
	$html .= '</tr>';
	$html .= '<tr>';
	$html .= '<td colspan="2">';
	if($action=="userPackage")
	{
		$html .= '<input type="submit" name="btnSubmit" id="btnSubmit" value="Save" />';
	}
	else if($action=="reviewPackage" && $is_reviewed==0)
	{
		$html .= '<input type="submit" name="btnSubmit" id="btnSubmit" value="Review" />';
	}
	else if($action=="reviewPackage" && $is_reviewed==1)
	{
		$html .= '<input type="submit" name="btnSubmit" id="btnSubmit" value="Second Review" />';
	}
	
	$html .= '</td>';
	$html .= '</tr>';
	$html .= '<tr>';
	$html .= '<td>&nbsp;';
	$html .= '</td>';
	$html .= '</tr>';
	$html .= '<tr>';
	$html .= '<td colspan="2">';
	if(strlen($cropped_src)>0)
	{
        	$html .= '<a  style="float:right;cursor: pointer;position: relative;top: 0px;text-decoration:underline;" href="'.$cropped_src.'" class="pirobox_gall" title="Event Pic" >Download</a>';
	}
	if($is_reviewed==0 && strlen($cropped_src)>0)
	{
		$html .= "Document has not been reviewed yet.";
	}
	if($is_reviewed==1 && strlen($cropped_src)>0)
	{
		$html .= "Document has not been reviewed once.";
	}
	if($is_reviewed==2 && strlen($cropped_src)>0)
	{
		$html .= "<span style='width:350px;'>Document has not been reviewed Twice. You can not review it now. Thank you.</span>";
	}	
	$html .= '</td>';
	$html .= '</table>';
	$html .= '</form>';
	$html .= '</fieldset>';
	$html .= '</div>';
	
	echo $html;
}